package com.example.democommon.contasant;

/**
 * @version 1.0.0
 * @className: DynastyEnum
 * @description:
 * @author: rosszhang
 * @date: 2022/5/9 21:59
 */
public enum DynastyEnum {
    XIA(1,"夏朝"),SHANG(2,"商朝"),ZHOU(3,"周朝"),QIN(4,"秦朝"),
    XI(5,"西楚"),HAN(6,"汉朝"),SAN(7,"三国"),JIN(8,"晋朝"),NAN(9,"南北朝"),
    BEI(10,"北朝"),SUI(11,"隋朝"),TANG(12,"唐朝"),WU(13,"五代十国"),
    SUN(14,"宋朝"),LIAO(15,"辽"),XIXIA(16,"西夏"),JING(17,"金"),
    YUAN(18,"元朝"),MING(19,"明朝"),QING(20,"清朝");

    // 成员变量
    private int index;
    private String name;


    DynastyEnum(int index, String name) {
        this.name = name;
        this.index = index;
    }

    // 普通方法
    public static String getName(int index) {
        for (DynastyEnum c : DynastyEnum.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return XIA.getName();
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
